package space.jevin.jevinboot.entity;

import lombok.Data;
import space.jevin.jevinboot.exception.EnumErrorMessage;

/**
 * 请求响应包装类。
 */
@Data
public class RequestResult<T> {

    protected static final String EXTRA_MESSAGE_TEMPLATE = "（%s）";

    /**
     * 响应码
     */
    protected String code;

    /**
     * 响应消息
     */
    protected String message;

    /**
     * 数据类型
     */
    protected T data;

    public RequestResult(){

    }

    public RequestResult(EnumErrorMessage errorMessage, T data) {
        this.code = errorMessage.getCode();
        this.message = errorMessage.getMessage();
        this.data = data;
    }

    public void setCode(EnumErrorMessage errorMessage) {
        this.code = errorMessage.getCode();
        this.message = errorMessage.getMessage();
    }

    public void setCode(String code) {
        this.code = code;
    }

}
